//
//  main.m
//  字符串替换
//
//  Created by wenjim on 17/10/22.
//  Copyright © 2017年 WenJim. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    
    
    /*
    // 需求：将&符号替换为 /
    NSString * str = @"http:&&www.xiaoningle.com&img&logo.png";
    
    // OccurrencesOfString：要替换谁
    // withString：用谁替换
    NSString * newStr =  [str stringByReplacingOccurrencesOfString:@"&" withString:@"/"];
    NSLog(@"newStr = %@",newStr);
    */
    
    /*
    // 1.去除空格 2.将&替换成／
    NSString * str = @"   http:      &&www.    xiaoningle   .com&img&     logo.png";
    // 1.去除空格
    NSString * newStr = [str stringByReplacingOccurrencesOfString:@" " withString:@""];
    NSLog(@"newStr = %@",newStr);
    
    // 2.将&替换成／
    newStr = [newStr stringByReplacingOccurrencesOfString:@"&" withString:@"/"];
    NSLog(@"newStr = %@",newStr);
    */
    
    
    
    // 3.替换首尾
    
//    NSString * str = @"     http://www.xiaoningle.com/img/logo.png      ";
    
//    NSCharacterSet * set = [NSCharacterSet whitespaceCharacterSet];
//    NSString * newStr = [str stringByTrimmingCharactersInSet:set];
    
    NSString * str = @"HTTP://www.xiaoningle.com/img/LOGO.PNG";
    NSCharacterSet * set = [NSCharacterSet uppercaseLetterCharacterSet];
    NSString * newStr = [str stringByTrimmingCharactersInSet:set];
    
    NSLog(@"newStr = %@",newStr);
    
    
    return 0;
}
